﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccessLayer.Entity;
namespace DataAccessLayer.Adapter
{
    
    public class DanTocAdapter
    {
        clsKetNoiCSDL kn = new clsKetNoiCSDL();
        public DataTable LoadDanToc()
        {
            return kn.LoadDL("tbDanToc_SelectAll");
        }
        public void ThemDanToc(clsDanToc clsDT)
        {
            int Npa = 2;
            string sql = "tbDanToc_Insert";
            string[] name = new string[Npa];
            object []value=new object[Npa];
            name[0] = "@MaDT"; value[0] = clsDT.MaDanToc;
            name[1] = "@TenDanToc"; value[1] = clsDT.TenDanToc;
            kn.UpdateDL(sql,name,value,Npa);
        }
        public void SuaDanToc(clsDanToc clsDT)
        {
            int Npa = 2;
            string sql = "tbDanToc_Update";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDT"; value[0] = clsDT.MaDanToc;
            name[1] = "@TenDanToc"; value[1] = clsDT.TenDanToc;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public void XoaDanToc(clsDanToc clsDT)
        {
            int Npa = 1;
            string sql = "tbDanToc_Delete";
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDT"; value[0] = clsDT.MaDanToc;
            //name[1] = "@TenDanToc"; value[1] = clsDT.TenDanToc;
            kn.UpdateDL(sql, name, value, Npa);
        }
        public object KiemTraMa(clsDanToc clsDantoc)
        {
            string sql = "tbDanToc_KiemTraMa";
            int Npa = 1;
            string[]name=new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@MaDT"; value[0] = clsDantoc.MaDanToc;
            return kn.KTTrungMa(sql, name, value, Npa);
        }

        public object KiemTraTen(clsDanToc clsDantoc)
        {
            string sql = "tbDanToc_KiemTraTenDT";
            int Npa = 1;
            string[] name = new string[Npa];
            object[] value = new object[Npa];
            name[0] = "@TenDanToc"; value[0] = clsDantoc.TenDanToc;
            return kn.KTTrungMa(sql, name, value, Npa);
        }
    }
}
